package hu.issue.framework.web.tag;

import hu.issue.framework.web.validation.ErrorMessages;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.jsp.JspException;

class ErrorRenderer {

	public static void render(final ErrorMessages messages, final PrintWriter writer) throws JspException {
		if (messages == null) {
			return;
		}

		final List<String> errorMessages = messages.getErrorMessages();
		if (errorMessages.size() == 0) {
			return;
		}
		writer.println("<ul class=\"validation-error\">");
		for (final String errorMessage : errorMessages) {
			writer.print("<li>");
			writer.print(errorMessage);
			writer.println("</li>");
		}
		writer.println("</ul>");
	}
}
